﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agnes.Core;
using System.Drawing;
using Caliburn.Micro;
using System.Collections.ObjectModel;

namespace Agnes.TaskManager
{
    public class TaskSummaryViewModel 
        : DocumentPanelBase<TaskManager>
    {
        public TaskManager TaskManager { get; set; }

        public ObservableCollection<Object> SelectedRows { get; set; } 

        public TaskSummaryViewModel(TaskManager model)
            :base(model)
        {
            DisplayName = "任务报表";
            SelectedRows = new ObservableCollection<object>();
            SelectedRows.CollectionChanged += (sender, args) =>
                                                  {
                                                      if (SelectedRows.Count != 0)
                                                      {
                                                          TaskManagerService.TaskManager.SelectedTask = SelectedRows[0] as Task;
                                                      }
                                                      else
                                                      {
                                                          TaskManagerService.TaskManager.SelectedTask = null;
                                                      }
                                                  };

            TaskManager = TaskManagerService.TaskManager;
        }

        public void DataChanged()
        {
            
        }

        public override void Cancel()
        {

        }

        public override void PreViewClose(object sender, System.ComponentModel.CancelEventArgs e)
        {
            int i = 1;
        }

        public override void Save()
        {

        }

        protected override object CreateView()
        {
            return new TaskSummaryView();
        }
    }
}
